﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Century.Model.ViewModel
{
    public class CharValueViewModel
    {
        public int Id { get; set; }
        public string CharTypeDescription { get; set; }
        public string CharValueDescription { get; set; }
        public int CharTypeId { get; set; }
        public int? ParentId { get; set; }
        public int? Number { get; set; }
        public string Code { get; set; }

        public ICollection<CharValueTranslation> CharValueTranslations { get; set; }


        public string TranslatedText
        {
            get
            {
                CharValueTranslation translateValue = this.CharValueTranslations.FirstOrDefault(c => c.IsAvailable && c.Site == CurrentSite);
                if (translateValue == null)
                {
                    return string.Empty;
                }
                else
                {
                    return translateValue.Description;
                }
            }
        }


        public int OrderInList
        {
            get
            {
                CharValueTranslation translateValue = this.CharValueTranslations.FirstOrDefault(c => c.IsAvailable && c.Site == CurrentSite);
                if (translateValue == null)
                {
                    return 0;
                }
                else
                {
                    return translateValue.OrderInList;
                }
            }
        }


        public string CurrentSite { get; set; }
    }
}
